/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI_SIFACT;

import AccesoDatosAvanzado.AD_Categoria;
import AccesoDatosAvanzado.AD_Producto;
import AccesoDatosAvanzado.AD_Producto_Inventario;
import AccesoDatosAvanzado.AD_Producto_Proveedor;
import AccesoDatosAvanzado.AD_Proveedor;
import AccesoDatosSimple.cProducto;
import AccesoDatosSimple.cProducto_Inventario;
import AccesoDatosSimple.cProducto_Proveedor;
import GUI_Busquedas.Frm_busq_producto;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.SimpleDateFormat;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import sifact.conexion.cConexion;

/**
 *
 * @author Cyber Huevadictos
 */
public class Frm_Producto extends javax.swing.JFrame {

    private String txtnulos = "Los Campos Vacios son:\n";
    String fechaArticulo = "00/00/0000";
    AD_Proveedor obj1 = new AD_Proveedor();
    AD_Categoria obj2 = new AD_Categoria();

    /**
     * Creates new form Frm_Producto
     */
    public Frm_Producto() throws Exception {
        initComponents();
        //lleno el combo box        
        jComboBoxProv = obj1.cbmFullProveedor(jComboBoxProv);
        //lleno el combo box        
        jComboBoxCat = obj2.cbmFullCategoria(jComboBoxCat);

    }
//funcion para limpiar los campos

    private void CamposClean() {
        jTextFieldCodigo.setText(null);
        jTextFieldNomArt.setText(null);
        jTextPreCos.setText("0.00");
        jTextPreDistrib.setText("0.00");
        jTextFieldCantMin.setText("0");
        jTextFieldCantMax.setText("0");
        jTextFieldPrePublico.setText("0.00");
    }
//funcion para bloquear campos cuando es Insercion

    private void CamposInsert() {
        //texto
        jTextFieldNomArt.setEnabled(true);
        jTextPreCos.setEnabled(true);
        jTextPreDistrib.setEnabled(true);
        jTextFieldCantMin.setEnabled(true);
        jTextFieldCantMax.setEnabled(true);
        jTextFieldPrePublico.setEnabled(true);
        //Fechas
        jDateChooserFechComp.setEnabled(true);
        //CombosBox
        jComboBoxProv.setEnabled(true);
        jComboBoxCat.setEnabled(true);
        jComboBoxUnid.setEnabled(true);
        //botones
        jButtonBuscar.setEnabled(false);
        jButtonAceptar.setEnabled(true);
    }
//funcion para bloquear campos cuando es Actualizacion

    private void CamposUpdate() {
        //texto        
        jTextFieldNomArt.setEnabled(true);
        jTextPreCos.setEnabled(true);
        jTextPreDistrib.setEnabled(true);
        jTextFieldCantMin.setEnabled(true);
        jTextFieldCantMax.setEnabled(true);
        jTextFieldPrePublico.setEnabled(true);
        //Fechas
        jDateChooserFechComp.setEnabled(true);
        //CombosBox
        jComboBoxProv.setEnabled(true);
        jComboBoxCat.setEnabled(true);
        jComboBoxUnid.setEnabled(true);
        //botones
        jButtonBuscar.setEnabled(true);
        jButtonAceptar.setEnabled(false);
    }
//funcion para bloquear campos cuando es Eliminacion

    private void CamposDelete() {
        //texto
        jTextFieldNomArt.setEnabled(false);
        jTextPreCos.setEnabled(false);
        jTextPreDistrib.setEnabled(false);
        jTextFieldCantMin.setEnabled(false);
        jTextFieldCantMax.setEnabled(false);
        jTextFieldPrePublico.setEnabled(false);
        //Fechas
        jDateChooserFechComp.setEnabled(false);
        //CombosBox
        jComboBoxProv.setEnabled(false);
        jComboBoxCat.setEnabled(false);
        jComboBoxUnid.setEnabled(false);
        //botones
        jButtonBuscar.setEnabled(true);
        jButtonAceptar.setEnabled(false);
    }
//funcion que me permite verificar los campos nulos del formulario

    private boolean CamposNulos() {
        boolean band = false;

        if (jTextFieldNomArt.getText().trim().equals("")) {
            txtnulos = txtnulos + "NOMBRE\n";
            band = true;
        }
        if (jTextPreCos.getText().trim().equals("")) {
            txtnulos = txtnulos + "PRECIO DE COSTO\n";
            band = true;
        }
        if (jTextPreDistrib.getText().trim().equals("")) {
            txtnulos = txtnulos + "PRECIO DE VENTA\n";
            band = true;
        }
        if (jTextFieldPrePublico.getText().trim().equals("")) {
            txtnulos = txtnulos + "PRECIO DE PUBLICO\n";
            band = true;
        }
        if (jTextFieldCantMin.getText().trim().equals("")) {
            txtnulos = txtnulos + "CANTIDAD MINIMA\n";
            band = true;
        }
        if (jTextFieldCantMax.getText().trim().equals("")) {
            txtnulos = txtnulos + "CANTIDAD MAXIMA\n";
            band = true;
        }
        if (jComboBoxProv.getSelectedItem().toString().equals("Otra")) {
            txtnulos = txtnulos + "NO HAY PROVEEDOR ASIGNADO\n";
            band = true;
        }
        if (jComboBoxCat.getSelectedItem().toString().equals("Otra")) {
            txtnulos = txtnulos + "NO HAY CATEGORIA ASIGNADA\n";
            band = true;
        }
        //compruebo si el campo fecha es nulo
        try {
            SimpleDateFormat fechaPersonalizada = new SimpleDateFormat(jDateChooserFechComp.getDateFormatString());
            fechaArticulo = fechaPersonalizada.format(jDateChooserFechComp.getDate());
            //System.out.println(fecha);            
        } catch (NullPointerException ex) {
            txtnulos = txtnulos + "NO HAY FECHA ASIGNADA\n";
        }


        return band;
    }

    private void DatosFormulario(cProducto obj1, cProducto_Inventario obj2, cProducto_Proveedor obj3) {
        obj1.setNumIDProducto(Integer.parseInt(jTextFieldCodigo.getText()));
        obj1.setTxtNomProducto(jTextFieldNomArt.getText().toUpperCase());
        obj1.setTxtDescripUnid(jComboBoxUnid.getSelectedItem().toString());
        obj1.setNumPrecioCosto(Double.parseDouble(jTextPreCos.getText()));
        obj1.setNumPrecioVF(Double.parseDouble(jTextFieldPrePublico.getText()));
        obj1.setNumPrecioDist(Double.parseDouble(jTextPreDistrib.getText()));
        //convierto los nombres de Proveedor y Categoria en codigos
        try {
            obj1.setNumIDProveedor(AD_Proveedor.GetCodigo(jComboBoxProv.getSelectedItem().toString()));
            obj1.setNumIDCategoria(AD_Categoria.GetCodigo(jComboBoxCat.getSelectedItem().toString()));

        } catch (Exception ex) {
        }

        //datos para la tabla PRODUCTO_INVENTARIO
        obj2.setNumIDProducto(Integer.parseInt(jTextFieldCodigo.getText()));
        obj2.setDateFechaCompra(fechaArticulo);
        obj2.setNumCantMin(Double.parseDouble(jTextFieldCantMin.getText()));
        obj2.setNumCantActual(Double.parseDouble(jTextFieldCantMax.getText()));

        //datos para la tabla PRODUCTO_PROVEEDOR
        obj3.setNumIDProducto(obj2.getNumIDProducto());
        obj3.setNumIDProveedor(obj1.getNumIDProveedor());
    }
    //Asigno los datos devueltos en una busqueda    

    private void DatosFormularioBusqueda(String obj) throws Exception {
        String[] tupla = new String[10];
        String[] tupla2 = new String[5];
        String[] tupla3 = new String[3];
        //Productos
        tupla = AD_Producto.BuscarCodigo(obj);
        jTextFieldCodigo.setText(tupla[0]);
        jTextFieldNomArt.setText(tupla[1]);
        jComboBoxUnid.setSelectedItem(tupla[2]);
        //formtateo la salida a 2 decimales y punto
        DecimalFormatSymbols simbolos = new DecimalFormatSymbols();
        simbolos.setDecimalSeparator('.');
        DecimalFormat df = new DecimalFormat("#####.00", simbolos);
        jTextPreCos.setText(df.format(Double.parseDouble(tupla[3])));
        jTextFieldPrePublico.setText(df.format(Double.parseDouble(tupla[4])));
        jTextPreDistrib.setText(df.format(Double.parseDouble(tupla[7])));
        //PRODUCTO_INVENTARIO
        tupla2 = AD_Producto_Inventario.BuscarCodigo(tupla[0]);
        jTextFieldCantMin.setText(tupla2[1]);
        jTextFieldCantMax.setText(tupla2[2]);
        //jDateChooserFechComp.
        //PROVEEDOR
        tupla3 = AD_Proveedor.BuscarCodigo(tupla[5]);
        jComboBoxProv.setSelectedItem(tupla3[1]);
        //CATEGORIA
        tupla3 = AD_Categoria.BuscarCodigo(tupla[6]);
        jComboBoxCat.setSelectedItem(tupla3[1]);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanelOpciones = new javax.swing.JPanel();
        jRadioButtonInsert = new javax.swing.JRadioButton();
        jRadioButtonUpdate = new javax.swing.JRadioButton();
        jRadioButtonDelete = new javax.swing.JRadioButton();
        jButtonBuscar = new javax.swing.JButton();
        jPanelBotones = new javax.swing.JPanel();
        jButtonAceptar = new javax.swing.JButton();
        jButtonCancelar = new javax.swing.JButton();
        jTabbedPaneDatos = new javax.swing.JTabbedPane();
        jPanelDatos = new javax.swing.JPanel();
        jLabelCodigo = new javax.swing.JLabel();
        jTextFieldCodigo = new javax.swing.JTextField();
        jLabelNomArt = new javax.swing.JLabel();
        jTextFieldNomArt = new javax.swing.JTextField();
        jLabelUnid = new javax.swing.JLabel();
        jComboBoxUnid = new javax.swing.JComboBox();
        jLabelUnid1 = new javax.swing.JLabel();
        jLabelUnid2 = new javax.swing.JLabel();
        jLabelUnid3 = new javax.swing.JLabel();
        jLabelUnid4 = new javax.swing.JLabel();
        jTextPreCos = new javax.swing.JTextField();
        jTextPreDistrib = new javax.swing.JTextField();
        jLabelUnid5 = new javax.swing.JLabel();
        jLabelUnid6 = new javax.swing.JLabel();
        jLabelUnid7 = new javax.swing.JLabel();
        jComboBoxProv = new javax.swing.JComboBox();
        jComboBoxCat = new javax.swing.JComboBox();
        jTextFieldCantMin = new javax.swing.JTextField();
        jTextFieldCantMax = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        btnNewProv = new javax.swing.JButton();
        btnNewCat = new javax.swing.JButton();
        jDateChooserFechComp = new com.toedter.calendar.JDateChooser();
        jLabel4 = new javax.swing.JLabel();
        jTextFieldPrePublico = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("DETALLES PARA ARTICULO");

        jPanelOpciones.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "OPCIONES PARA ARTICULO", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 18))); // NOI18N

        buttonGroup1.add(jRadioButtonInsert);
        jRadioButtonInsert.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jRadioButtonInsert.setText("AGREGAR");
        jRadioButtonInsert.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButtonInsertMouseClicked(evt);
            }
        });

        buttonGroup1.add(jRadioButtonUpdate);
        jRadioButtonUpdate.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jRadioButtonUpdate.setText("MODIFICAR");
        jRadioButtonUpdate.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButtonUpdateMouseClicked(evt);
            }
        });

        buttonGroup1.add(jRadioButtonDelete);
        jRadioButtonDelete.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jRadioButtonDelete.setText("ELIMINAR");
        jRadioButtonDelete.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButtonDeleteMouseClicked(evt);
            }
        });

        jButtonBuscar.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButtonBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/16Nuvola_search_person.png"))); // NOI18N
        jButtonBuscar.setText("BUSCAR");
        jButtonBuscar.setEnabled(false);
        jButtonBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBuscarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelOpcionesLayout = new javax.swing.GroupLayout(jPanelOpciones);
        jPanelOpciones.setLayout(jPanelOpcionesLayout);
        jPanelOpcionesLayout.setHorizontalGroup(
            jPanelOpcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelOpcionesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelOpcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanelOpcionesLayout.createSequentialGroup()
                        .addComponent(jRadioButtonInsert)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 73, Short.MAX_VALUE)
                        .addComponent(jRadioButtonUpdate))
                    .addComponent(jButtonBuscar))
                .addGap(76, 76, 76)
                .addComponent(jRadioButtonDelete)
                .addContainerGap())
        );
        jPanelOpcionesLayout.setVerticalGroup(
            jPanelOpcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelOpcionesLayout.createSequentialGroup()
                .addGroup(jPanelOpcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jRadioButtonInsert)
                    .addComponent(jRadioButtonUpdate)
                    .addComponent(jRadioButtonDelete))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButtonBuscar))
        );

        jPanelBotones.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jButtonAceptar.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButtonAceptar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/16px-Crystal_Clear_action_apply.png"))); // NOI18N
        jButtonAceptar.setText("ACEPTAR");
        jButtonAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAceptarActionPerformed(evt);
            }
        });

        jButtonCancelar.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButtonCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/16px-Crystal_Clear_action_button_cancel.png"))); // NOI18N
        jButtonCancelar.setText("CANCELAR");
        jButtonCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCancelarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelBotonesLayout = new javax.swing.GroupLayout(jPanelBotones);
        jPanelBotones.setLayout(jPanelBotonesLayout);
        jPanelBotonesLayout.setHorizontalGroup(
            jPanelBotonesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelBotonesLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButtonAceptar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 54, Short.MAX_VALUE)
                .addComponent(jButtonCancelar)
                .addContainerGap())
        );
        jPanelBotonesLayout.setVerticalGroup(
            jPanelBotonesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelBotonesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelBotonesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonAceptar)
                    .addComponent(jButtonCancelar))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPaneDatos.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jLabelCodigo.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelCodigo.setText("CODIGO:");

        jTextFieldCodigo.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTextFieldCodigo.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jTextFieldCodigo.setEnabled(false);
        jTextFieldCodigo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldCodigoKeyTyped(evt);
            }
        });

        jLabelNomArt.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelNomArt.setText("NOMBRE:");

        jTextFieldNomArt.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTextFieldNomArt.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jTextFieldNomArt.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldNomArtKeyTyped(evt);
            }
        });

        jLabelUnid.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelUnid.setText("UNIDADES:");

        jComboBoxUnid.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jComboBoxUnid.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "lb", "mts", "qq", "und", "Kg", "gr", "oz", "lts" }));

        jLabelUnid1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelUnid1.setText("PRECIO COSTO:");

        jLabelUnid2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelUnid2.setText("PRECIO DISTRIBUIDOR:");

        jLabelUnid3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelUnid3.setText("PROVEEDOR:");

        jLabelUnid4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelUnid4.setText("CATEGORIA:");

        jTextPreCos.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTextPreCos.setText("0.0000");
        jTextPreCos.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextPreCosKeyTyped(evt);
            }
        });

        jTextPreDistrib.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTextPreDistrib.setText("0.0000");
        jTextPreDistrib.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextPreDistribKeyTyped(evt);
            }
        });

        jLabelUnid5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelUnid5.setText("FECHA DE COMPRA:");

        jLabelUnid6.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelUnid6.setText("CANTIDAD MINIMA:");

        jLabelUnid7.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelUnid7.setText("CANTIDAD ACTUAL:");

        jComboBoxProv.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jComboBoxProv.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jComboBoxProvItemStateChanged(evt);
            }
        });

        jComboBoxCat.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jComboBoxCat.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jComboBoxCatItemStateChanged(evt);
            }
        });

        jTextFieldCantMin.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTextFieldCantMin.setText("000");
        jTextFieldCantMin.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldCantMinKeyTyped(evt);
            }
        });

        jTextFieldCantMax.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTextFieldCantMax.setText("000");
        jTextFieldCantMax.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldCantMaxKeyTyped(evt);
            }
        });

        jLabel1.setText("Ejm: 25.63");

        jLabel3.setText("Ejm: 2012/08/15");

        btnNewProv.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/16x16_add.png"))); // NOI18N
        btnNewProv.setText("Nuevo");
        btnNewProv.setEnabled(false);
        btnNewProv.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnNewProvMouseClicked(evt);
            }
        });
        btnNewProv.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNewProvActionPerformed(evt);
            }
        });

        btnNewCat.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/16x16_add.png"))); // NOI18N
        btnNewCat.setText("Nuevo");
        btnNewCat.setEnabled(false);
        btnNewCat.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnNewCatMouseClicked(evt);
            }
        });
        btnNewCat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNewCatActionPerformed(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel4.setText("PRECIO PUBLICO:");

        jTextFieldPrePublico.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTextFieldPrePublico.setText("0.0000");
        jTextFieldPrePublico.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldPrePublicoKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout jPanelDatosLayout = new javax.swing.GroupLayout(jPanelDatos);
        jPanelDatos.setLayout(jPanelDatosLayout);
        jPanelDatosLayout.setHorizontalGroup(
            jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelDatosLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelDatosLayout.createSequentialGroup()
                        .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabelUnid3)
                            .addComponent(jLabelUnid4)
                            .addComponent(jLabelCodigo))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanelDatosLayout.createSequentialGroup()
                                .addComponent(jTextFieldCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(178, 178, 178))
                            .addGroup(jPanelDatosLayout.createSequentialGroup()
                                .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jComboBoxCat, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jComboBoxProv, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGap(18, 18, 18)
                                .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(btnNewCat, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(btnNewProv, javax.swing.GroupLayout.Alignment.TRAILING))
                                .addContainerGap())))
                    .addGroup(jPanelDatosLayout.createSequentialGroup()
                        .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanelDatosLayout.createSequentialGroup()
                                .addComponent(jLabelUnid2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jTextPreDistrib, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel4)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextFieldPrePublico, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(jPanelDatosLayout.createSequentialGroup()
                                    .addComponent(jLabelUnid5)
                                    .addGap(28, 28, 28)
                                    .addComponent(jDateChooserFechComp, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jLabel3))
                                .addGroup(jPanelDatosLayout.createSequentialGroup()
                                    .addComponent(jLabelUnid6)
                                    .addGap(14, 14, 14)
                                    .addComponent(jTextFieldCantMin, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jLabelUnid7)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jTextFieldCantMax, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanelDatosLayout.createSequentialGroup()
                                    .addComponent(jLabelUnid)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jComboBoxUnid, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jLabelUnid1)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jTextPreCos, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jLabel1))
                                .addGroup(jPanelDatosLayout.createSequentialGroup()
                                    .addComponent(jLabelNomArt)
                                    .addGap(30, 30, 30)
                                    .addComponent(jTextFieldNomArt))))
                        .addContainerGap(16, Short.MAX_VALUE))))
        );
        jPanelDatosLayout.setVerticalGroup(
            jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelDatosLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelUnid3)
                    .addComponent(jComboBoxProv, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnNewProv))
                .addGap(4, 4, 4)
                .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBoxCat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelUnid4)
                    .addComponent(btnNewCat))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelCodigo))
                .addGap(8, 8, 8)
                .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldNomArt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelNomArt))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBoxUnid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelUnid)
                    .addComponent(jLabelUnid1)
                    .addComponent(jTextPreCos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addGap(6, 6, 6)
                .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelUnid2)
                    .addComponent(jTextPreDistrib, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(jTextFieldPrePublico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelUnid5)
                    .addComponent(jDateChooserFechComp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addGap(9, 9, 9)
                .addGroup(jPanelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldCantMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelUnid6)
                    .addComponent(jTextFieldCantMax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelUnid7))
                .addContainerGap(14, Short.MAX_VALUE))
        );

        jTabbedPaneDatos.addTab("DATOS  DEL ARTICULO", jPanelDatos);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanelOpciones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(74, 74, 74)
                        .addComponent(jPanelBotones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jTabbedPaneDatos, javax.swing.GroupLayout.PREFERRED_SIZE, 438, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(18, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanelOpciones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTabbedPaneDatos, javax.swing.GroupLayout.PREFERRED_SIZE, 298, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanelBotones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jRadioButtonInsertMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButtonInsertMouseClicked
        // TODO add your handling code here:
        CamposInsert();
        CamposClean();
        int e;
        try {
            e = AD_Producto.GetId();
            e += 1;
            if (e >= 0) {
                jTextFieldCodigo.setText(Integer.toString(e));
            } else {
                JOptionPane.showMessageDialog(null, "Existe el siguiente error:\n" + e, "ERROR AL OBTENER CODIGO", JOptionPane.ERROR_MESSAGE);
            }
            cConexion.cerrar();
        } catch (Exception ex) {
            Logger.getLogger(Frm_Clientes.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jRadioButtonInsertMouseClicked

    private void jRadioButtonUpdateMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButtonUpdateMouseClicked
        // TODO add your handling code here:
        CamposUpdate();
        CamposClean();
    }//GEN-LAST:event_jRadioButtonUpdateMouseClicked

    private void jRadioButtonDeleteMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButtonDeleteMouseClicked
        // TODO add your handling code here:
        CamposDelete();
        CamposClean();
    }//GEN-LAST:event_jRadioButtonDeleteMouseClicked

    private void jButtonBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBuscarActionPerformed
        // TODO add your handling code here:
        if (jRadioButtonUpdate.isSelected() == true || jRadioButtonDelete.isSelected() == true) {
            String objcadena = "";
            Frm_busq_producto.setDefaultLookAndFeelDecorated(true);
            Frm_busq_producto obj;
            try {
                obj = new Frm_busq_producto(null, true, objcadena);
                obj.setVisible(true);
                if (!obj.getObjcadena().equals("")) {
                    DatosFormularioBusqueda(obj.getObjcadena());
                }
                cConexion.cerrar();
            } catch (Exception ex) {
                Logger.getLogger(Frm_Clientes.class.getName()).log(Level.SEVERE, null, ex);
            }

            //        DatosfrmBusq(obj.getObjcli());
            jButtonAceptar.setEnabled(true);
        }
    }//GEN-LAST:event_jButtonBuscarActionPerformed

    private void jButtonAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAceptarActionPerformed

        //codigo para realizar las diferentes tareas Insert,Update,Delete
        Exception e;
        if (CamposNulos() == true) {//verifico que campo se encuentra vacio y advierto
            JOptionPane.showMessageDialog(null, txtnulos, "Campos Vacios", JOptionPane.INFORMATION_MESSAGE);
            txtnulos = "Los Campos Vacios son:\n";
        } else {//Inicio la Insercion
            if (jRadioButtonInsert.isSelected() == true) {
                cProducto obj1 = new cProducto();
                cProducto_Inventario obj2 = new cProducto_Inventario();
                cProducto_Proveedor obj3 = new cProducto_Proveedor();
                //Lleno los datos del formulario
                DatosFormulario(obj1, obj2, obj3);
                try {
                    e = AD_Producto.Insertar(obj1);
                    e = AD_Producto_Inventario.Insertar(obj2);
                    e = AD_Producto_Proveedor.Insertar(obj3);
                    if (e == null) {
                        JOptionPane.showMessageDialog(null, "Se ha sido ingresado correctamente", "INSERTAR", JOptionPane.INFORMATION_MESSAGE);
                    } else {
                        JOptionPane.showMessageDialog(null, "Existe el siguiente error:\n" + e, "ERROR AL INSERTAR", JOptionPane.ERROR_MESSAGE);
                    }
                    dispose();
                    cConexion.cerrar();
                } catch (Exception ex) {
                    Logger.getLogger(Frm_Clientes.class.getName()).log(Level.SEVERE, null, ex);
                }
            }//Terminamos con la Insercion
            else {//Inicio de Actualizacion
                if (jRadioButtonUpdate.isSelected() == true) {
                    cProducto obj1 = new cProducto();
                    cProducto_Inventario obj2 = new cProducto_Inventario();
                    cProducto_Proveedor obj3 = new cProducto_Proveedor();
                    //Lleno los datos del formulario
                    DatosFormulario(obj1, obj2, obj3);
                    try {
                        e = AD_Producto.Actualizar(obj1);
                        e = AD_Producto_Inventario.Actualizar(obj2);
                        e = AD_Producto_Proveedor.Actualizar(obj3);
                        if (e == null) {
                            JOptionPane.showMessageDialog(null, "Los datos se han actualizado correctamente", "MODIFICAR", JOptionPane.INFORMATION_MESSAGE);
                        } else {
                            JOptionPane.showMessageDialog(null, "Existe el siguiente error:\n" + e, "ERROR AL MODIFICAR", JOptionPane.ERROR_MESSAGE);
                        }
                        dispose();
                        cConexion.cerrar();
                    } catch (Exception ex) {
                        Logger.getLogger(Frm_Clientes.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }//terminanos con la Actualizacion
                else {//Iniciamos la Eliminacion
                    try {

                        e = AD_Producto_Proveedor.Eliminar(Integer.parseInt(jTextFieldCodigo.getText()));
                        e = AD_Producto_Inventario.Eliminar(Integer.parseInt(jTextFieldCodigo.getText()));
                        e = AD_Producto.Eliminar(Integer.parseInt(jTextFieldCodigo.getText()));
                        if (e == null) {
                            JOptionPane.showMessageDialog(null, "Los datos se han Eliminado correctamente", "ELIMINAR", JOptionPane.INFORMATION_MESSAGE);
                        } else {
                            JOptionPane.showMessageDialog(null, "Existe el siguiente error:\n" + e, "ERROR AL ELIMINAR", JOptionPane.ERROR_MESSAGE);
                        }
                        dispose();
                        cConexion.cerrar();
                    } catch (Exception ex) {
                        Logger.getLogger(Frm_Clientes.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }//Terminamos la Eliminacion
            }
        }
    }//GEN-LAST:event_jButtonAceptarActionPerformed

    private void jButtonCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelarActionPerformed
        try {
            // TODO add your handling code here:
            dispose();
            cConexion.cerrar();
        } catch (Exception ex) {
            Logger.getLogger(Frm_Clientes.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButtonCancelarActionPerformed

    private void jTextFieldCodigoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldCodigoKeyTyped
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldCodigoKeyTyped

    private void jTextFieldNomArtKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldNomArtKeyTyped
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFieldNomArtKeyTyped

    private void btnNewProvMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnNewProvMouseClicked
        // TODO add your handling code here:        
    }//GEN-LAST:event_btnNewProvMouseClicked

    private void btnNewProvActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewProvActionPerformed
        // TODO add your handling code here:
        dispose();
        Frm_Proveedor obj = new Frm_Proveedor();
        obj.setVisible(true);
        obj.setLocationRelativeTo(null);
    }//GEN-LAST:event_btnNewProvActionPerformed

    private void btnNewCatMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnNewCatMouseClicked
        // TODO add your handling code here:     
    }//GEN-LAST:event_btnNewCatMouseClicked

    private void btnNewCatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewCatActionPerformed
        // TODO add your handling code here:
        dispose();
        Frm_Categoria obj = new Frm_Categoria();
        obj.setVisible(true);
        obj.setLocationRelativeTo(null);
    }//GEN-LAST:event_btnNewCatActionPerformed

    private void jTextPreCosKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextPreCosKeyTyped
        // TODO add your handling code here:
        char t = evt.getKeyChar();
        if (!((t >= '0' && t <= '9') || t == '.') || jTextPreCos.getText().length() > 10) {
            evt.setKeyChar('\b');
        }
        if (t == java.awt.event.KeyEvent.VK_ENTER) {
            String[] tupla = new String[10];
            int codigo = 0;
            double v1 = 0;
            double v2 = 0;
            try {
                codigo = AD_Categoria.GetCodigo(jComboBoxCat.getSelectedItem().toString());
                tupla = AD_Categoria.BuscarCodigo(Integer.toString(codigo));

                v1 = Double.parseDouble(tupla[2]) / 100;//distribuidor
                v2 = Double.parseDouble(tupla[3]) / 100;//consum final

                v1 = Double.parseDouble(jTextPreCos.getText()) * v1;
                v2 = Double.parseDouble(jTextPreCos.getText()) * v2;
                //formtateo la salida a 2 decimales y punto
                DecimalFormatSymbols simbolos = new DecimalFormatSymbols();
                simbolos.setDecimalSeparator('.');
                DecimalFormat df = new DecimalFormat("#####.00", simbolos);

                jTextPreDistrib.setText(df.format(Double.parseDouble(jTextPreCos.getText()) + v1));
                jTextFieldPrePublico.setText(df.format(Double.parseDouble(jTextPreCos.getText()) + v2));

            } catch (Exception ex) {
                Logger.getLogger(Frm_Producto.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }//GEN-LAST:event_jTextPreCosKeyTyped

    private void jTextPreDistribKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextPreDistribKeyTyped
        // TODO add your handling code here:
        char t = evt.getKeyChar();
        if (!((t >= '0' && t <= '9') || t == '.') || jTextPreDistrib.getText().length() > 10) {
            evt.setKeyChar('\b');
        }
    }//GEN-LAST:event_jTextPreDistribKeyTyped

    private void jTextFieldCantMinKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldCantMinKeyTyped
        // TODO add your handling code here:
        char t = evt.getKeyChar();
        if (!((t >= '0' && t <= '9')) || jTextFieldCantMin.getText().length() > 6) {
            evt.setKeyChar('\b');
        }
    }//GEN-LAST:event_jTextFieldCantMinKeyTyped

    private void jTextFieldCantMaxKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldCantMaxKeyTyped
        // TODO add your handling code here:
        char t = evt.getKeyChar();
        if (!((t >= '0' && t <= '9')) || jTextFieldCantMax.getText().length() > 6) {
            evt.setKeyChar('\b');
        }
    }//GEN-LAST:event_jTextFieldCantMaxKeyTyped

    private void jComboBoxProvItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBoxProvItemStateChanged
        // TODO add your handling code here:
        if (jComboBoxProv.getSelectedItem().toString().equals("Otra") || jComboBoxProv.getSelectedItem().toString().equals("")) {
            btnNewProv.setEnabled(true);
        } else {
            btnNewProv.setEnabled(false);
        }
    }//GEN-LAST:event_jComboBoxProvItemStateChanged

    private void jComboBoxCatItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBoxCatItemStateChanged
        // TODO add your handling code here:
        if (jComboBoxCat.getSelectedItem().toString().equals("Otra") || jComboBoxCat.getSelectedItem().toString().equals("")) {
            btnNewCat.setEnabled(true);
        } else {
            btnNewCat.setEnabled(false);
        }
    }//GEN-LAST:event_jComboBoxCatItemStateChanged

    private void jTextFieldPrePublicoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldPrePublicoKeyTyped
        // TODO add your handling code here:
        char t = evt.getKeyChar();
        if (!((t >= '0' && t <= '9') || t == '.') || jTextPreDistrib.getText().length() > 10) {
            evt.setKeyChar('\b');
        }
    }//GEN-LAST:event_jTextFieldPrePublicoKeyTyped

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Frm_Producto.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Frm_Producto.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Frm_Producto.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Frm_Producto.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                try {
                    new Frm_Producto().setVisible(true);
                } catch (Exception ex) {
                    Logger.getLogger(Frm_Producto.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnNewCat;
    private javax.swing.JButton btnNewProv;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JButton jButtonAceptar;
    private javax.swing.JButton jButtonBuscar;
    private javax.swing.JButton jButtonCancelar;
    private javax.swing.JComboBox jComboBoxCat;
    private javax.swing.JComboBox jComboBoxProv;
    private javax.swing.JComboBox jComboBoxUnid;
    private com.toedter.calendar.JDateChooser jDateChooserFechComp;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabelCodigo;
    private javax.swing.JLabel jLabelNomArt;
    private javax.swing.JLabel jLabelUnid;
    private javax.swing.JLabel jLabelUnid1;
    private javax.swing.JLabel jLabelUnid2;
    private javax.swing.JLabel jLabelUnid3;
    private javax.swing.JLabel jLabelUnid4;
    private javax.swing.JLabel jLabelUnid5;
    private javax.swing.JLabel jLabelUnid6;
    private javax.swing.JLabel jLabelUnid7;
    private javax.swing.JPanel jPanelBotones;
    private javax.swing.JPanel jPanelDatos;
    private javax.swing.JPanel jPanelOpciones;
    private javax.swing.JRadioButton jRadioButtonDelete;
    private javax.swing.JRadioButton jRadioButtonInsert;
    private javax.swing.JRadioButton jRadioButtonUpdate;
    private javax.swing.JTabbedPane jTabbedPaneDatos;
    private javax.swing.JTextField jTextFieldCantMax;
    private javax.swing.JTextField jTextFieldCantMin;
    private javax.swing.JTextField jTextFieldCodigo;
    private javax.swing.JTextField jTextFieldNomArt;
    private javax.swing.JTextField jTextFieldPrePublico;
    private javax.swing.JTextField jTextPreCos;
    private javax.swing.JTextField jTextPreDistrib;
    // End of variables declaration//GEN-END:variables
}
